/**
 * 
 */
package es.uma.scgt.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import es.uma.scgt.dao.RolDao;
import es.uma.scgt.modelo.Rol;
import es.uma.scgt.modelo.Usuario;

/**
 * @author Vaio
 *
 */
@Repository
public class RolDaoJpa implements RolDao {
	
	@Autowired
	private SessionFactory session;

	/* (non-Javadoc)
	 * @see es.uma.scgt.dao.RolDao#listaRol()
	 */
	@SuppressWarnings("unchecked")
	public List<Rol> listaRol() {
		return (List<Rol>)session.getCurrentSession().createQuery("from Rol").list();
	}

	/* (non-Javadoc)
	 * @see es.uma.scgt.dao.RolDao#getRolPorId(int)
	 */
	public Rol getRolPorId(int id) {
		return (Rol)session.getCurrentSession().createQuery("from Rol r where r.id = :id").setParameter("id", id).uniqueResult();
	}

}
